//头部
var headerNav = document.createElement('div');
headerNav.className = "";
headerNav.innerHTML =
		'<nav class="navbar" role="navigation">'+
				'<div class="container-fluid"> '+
				'<div class="navbar-header">'+
					'<a class="navbar-brand" href="#"><img src="../img/logo-01.png"/></a>'+
				'</div>'+
				'<div>'+
					'<ul class="nav navbar-nav">'+
/*						'<li class="dropdown">'+
							'<a href="#" class="dropdown-toggle" data-toggle="dropdown">肉类数据</a>'+
							'<ul class="dropdown-menu">'+
								'<li><a href="#"><img class="r-arrow2" src="../img/1-arrow.png">肉类数据一</a></li>'+
							'</ul>'+
						'</li>'+
						'<li class="dropdown">'+
							'<a href="#" class="dropdown-toggle" data-toggle="dropdown">蔬菜数据</a>'+
							'<ul class="dropdown-menu">'+
								'<li><a href="#"><img class="r-arrow2" src="../img/1-arrow.png">蔬菜数据一</a></li>'+
							'</ul>'+
						'</li>'+
						'<li class="dropdown">'+
							'<a href="#" class="dropdown-toggle" data-toggle="dropdown">检验检疫</a>'+
							'<ul class="dropdown-menu">'+
								'<li><a href="#"><img class="r-arrow2" src="../img/1-arrow.png">检验检疫一</a></li>'+
							'</ul>'+
						'</li>'+
						'<li class="dropdown">'+
							'<a href="#" class="dropdown-toggle" data-toggle="dropdown">数据上报</a>'+
							'<ul class="dropdown-menu">'+
								'<li><a href="#"><img class="r-arrow2" src="../img/1-arrow.png">蔬菜刷卡登记</a></li>'+
								'<li><a href="#"><img class="r-arrow2" src="../img/1-arrow.png">蔬菜产地进货</a></li>'+
								'<li><a href="#"><img class="r-arrow2" src="../img/1-arrow.png">新增蔬菜档案</a></li>'+
								'<li><a href="#"><img class="r-arrow2" src="../img/1-arrow.png">新增销售数据</a></li>'+
							'</ul>'+
						'</li>'+*/
						'<li class="dropdown">'+
                            '<a href="#" class="icon iconfont" data-toggle="dropdown">&#xe613;&ensp;当前操作员</a>'+
                            '<ul class="dropdown-menu">'+
								'<li><a href="ChangePassword.html"><img class="r-arrow2" src="../img/1-arrow.png">密码修改</a></li>'+
								'<li><a id="logout" onclick="loginOut()"><img class="r-arrow2" src="../img/1-arrow.png">退出登录</a></li>'+
							'</ul>'+
						'</li>'+
					'</ul>'+
				'</div>'+
				'</div>'+
			'</nav>';
$(".top-nav").append(headerNav);

$(".top-nav-a a").each(function() {
	$this = $(this);
	if($this[0].href == String(window.location)) {
		$this.addClass("nav-cur");
	}
});

//存储token

function setToken(value){  
    var data = mystorage.get("test");
    var data = []; //定义一个空数组
    data.unshift(value);    //搜索词添加到数组中
    mystorage.set("test",data);  //存储到本地化存储中
}

//获取当前日期的函数 
function time_rota(controlId) { 
	var now = new Date(); 
	var h = now.getFullYear(); 
	var m = (now.getMonth() + 1>9) ? now.getMonth() + 1 : "0"+(now.getMonth() + 1); 
	var s = (now.getDate()>9)  ? now.getDate()  : "0"+now.getDate(); 
	var date = h + "-" + m + "-" + s; 
	var controlDate = controlId.val();
	if(controlDate=='' || controlDate ==null){
	controlId.val(date); 
	}
}

//获取当前日期往前推一个月的函数 
function time_rota2(controlId) { 
	var now = new Date(); 
	var date = getLastMonthTime(now); 
	var controlDate = controlId.val();
	if(controlDate=='' || controlDate ==null){
	controlId.val(date); 
	}
}

// 获取上一个月时间,返回yyyy-MM-dd字符串
function getLastMonthTime(date){
    //  1    2    3    4    5    6    7    8    9   10    11   12月
    var daysInMonth = [0,31,28,31,30,31,30,31,31,30,31,30,31];
    var strYear = date.getFullYear();
    var strDay = date.getDate();
    var strMonth = date.getMonth()+1;
    //一、解决闰年平年的二月份天数   //平年28天、闰年29天//能被4整除且不能被100整除的为闰年,或能被100整除且能被400整除
    if (((strYear % 4) === 0) && ((strYear % 100)!==0) || ((strYear % 400)===0)){
        daysInMonth[2] = 29;
    }
    if(strMonth - 1 === 0) //二、解决跨年问题
    {
        strYear -= 1;
        strMonth = 12;
    }
    else
    {
        strMonth -= 1;
    }
	//  strDay = daysInMonth[strMonth] >= strDay ? strDay : daysInMonth[strMonth];
    strDay = Math.min(strDay,daysInMonth[strMonth]);//三、前一个月日期不一定和今天同一号，例如3.31的前一个月日期是2.28；9.30前一个月日期是8.30
 
    if(strMonth<10)//给个位数的月、日补零
    {
        strMonth="0"+strMonth;
    }
    if(strDay<10)
    {
        strDay="0"+strDay;
    }
    var datastr = strYear+"-"+strMonth+"-"+strDay;
    return datastr;
}


var mystorage = (function mystorage(){
    var ms = "mystorage";
    var storage=window.localStorage;
    if(!window.localStorage){
        alert("浏览器不支持localstorage");
        return false;
    }
    var set = function(key,value){
        //存储
        var mydata = storage.getItem(ms);
        if(!mydata){
            this.init();
            mydata = storage.getItem(ms);
        }
        mydata = JSON.parse(mydata);
        mydata.data[key] = value;
        storage.setItem(ms,JSON.stringify(mydata));
        return mydata.data;
    };
    var get = function(key){
        //读取
        var mydata = storage.getItem(ms);
        if(!mydata){
            return false;
        }
        mydata = JSON.parse(mydata);
        return mydata.data[key];
    };
    var remove = function(key){
        //读取
        var mydata = storage.getItem(ms);
        if(!mydata){
            return false;
        }
        mydata = JSON.parse(mydata);
        delete mydata.data[key];
        storage.setItem(ms,JSON.stringify(mydata));
        return mydata.data;
    };
    var clear = function(){
        //清除对象
        storage.removeItem(ms);
    };
    var init = function(){
      storage.setItem(ms,'{"data":{}}');
    };
    return {
        set : set,
        get : get,
        remove : remove,
        init : init,
        clear : clear
    };
    
    
})();

var authToken = mystorage.get("test");
var validParam = mystorage.get("loginName");
var userNumber = mystorage.get("userCode");
var loginUserName = mystorage.get("userName");
//var epId=mystorage.get('entpInfo').epId;
//var isEpId = '&epId='+epId;
var isLogin ='?validParam='+validParam+"&authToken="+authToken;
